def vigenere_encrypt(plaintext, key):
    if not plaintext.isalpha() or not key.isalpha():
        raise ValueError
    plaintext = plaintext.upper()
    key = key.upper()
    output = ""
    count = 0
    for c in plaintext:
        p_val = (ord(c) - 65)
        k_val = (ord(key[count % len(key)]) - 65)
        output += chr(((p_val + k_val) % 26) + 65)
        count += 1
    return output

def vigenere_decrypt(ciphertext, key):
    if not ciphertext.isalpha() or not key.isalpha():
        raise ValueError
    ciphertext = ciphertext.upper()
    key = key.upper()
    output = ""
    count = 0
    for c in ciphertext:
        c_val = (ord(c) - 65)
        k_val = (ord(key[count % len(key)]) - 65)
        output += chr(((c_val - k_val) % 26)  + 65)
        count += 1
    return output.lower()